package com.zbkj.service.dao.client;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zbkj.common.model.client.agent.WeekTask;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 用户每日任务表 Mapper 接口
 * @author: 零风
 * @since 2024-01-01
 */
public interface WeekTaskDao extends BaseMapper<WeekTask> {

    /**
     * 查询需要生成周任务的用户列表
     * 
     * @return 用户列表
     */
    @Select("SELECT " +
            "   l.location_result as locationResult, " +
            "   a.id as userId, " +
            "   a.mer_id as merId " +
            "FROM " +
            "   eb_client_user_location l " +
            "   RIGHT JOIN eb_system_admin a ON l.mer_id = a.mer_id and a.is_del=0 " +
            "WHERE " +
            "   l.is_del=0")
    List<Map<String, Object>> selectWeekTaskUserList();

    /**
     * 根据商户ID查询需要生成周任务的用户列表
     * @param merId 商户ID
     * @return 用户列表
     */
    @Select("SELECT " +
            "   l.location_result as locationResult, " +
            "   a.id as userId, " +
            "   a.mer_id as merId " +
            "FROM " +
            "   eb_client_user_location l " +
            "   RIGHT JOIN eb_system_admin a ON l.mer_id = a.mer_id and a.is_del=0 " +
            "WHERE " +
            "   l.is_del=0 AND l.mer_id = #{merId}")
    List<Map<String, Object>> selectWeekTaskUserListByMerId(@Param("merId") Integer merId);
} 